package com.coda.mapper;

import com.coda.annotation.AutoFill;
import com.coda.entity.LeaseTerm;
import com.coda.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LeaseTermMapper {
    /**
     * 增加租期信息
     * @param leaseTerm
     */
    @AutoFill(OperationType.INSERT)
    void insert(LeaseTerm leaseTerm);

    /**
     * 更新租期信息
     * @param leaseTerm
     */
    @AutoFill(OperationType.UPDATE)
    void update(LeaseTerm leaseTerm);

    /**
     * 查询全部租期信息
     * @return
     */
    @Select("select * from lease_term")
    List<LeaseTerm> list();

    /**
     * 根据id删除租期
     * @param id
     */
    @Delete("delete from lease_term where id = #{id}")
    void delete(Long id);

    /**
     * 获取租期信息
     * @param leaseTermId
     * @return
     */
    @Select("select * from lease_term where id = #{leaseTermId}")
    LeaseTerm getLeaseTerm(Long leaseTermId);
}
